#!/usr/bin/env python

import sys
from datetime import date, timedelta

def on_help():
    print "Usage: %s 2010 01 23 or %s 20100123" % (sys.argv[0], sys.argv[0])

try:
    if len(sys.argv) == 2:
        year = int(sys.argv[1][0:4])
        month = int(sys.argv[1][4:6])
        day = int(sys.argv[1][6:8])
    else:
        year = int(sys.argv[1])
        month = int(sys.argv[2])
        day = int(sys.argv[3])

    the_date = date(year, month, day)
    print the_date.strftime('%Y%j')
except:
    on_help()
    sys.exit(1)

